//
//  ZMYBookCommenTableViewCell.m
//  奇阅
//
//  Created by 奇阅科技 on 14-11-10.
//  Copyright (c) 2014年 奇阅科技. All rights reserved.
//

#import "ZMYBookCommenTableViewCell.h"
#import "Config.h"
@implementation ZMYBookCommenTableViewCell

- (void)awakeFromNib {
    // Initialization code
    [self.headImageView addImageFullViewAnimation];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)likeClick:(id)sender {
    UserAccount *user = [UserAccount currentAccount];
    LikeComment *like = [LikeComment new];
    like.articleid = self.comment.articleid;
    like.commentid = self.comment.commentid;
    if (!user) {
        like.uid = @"love";
    } else {
        like.uid = user.uid;
    }
    if ([[ZMYLKDB getLKDBHelper]getIsLike:like]) {
        if ([self.likeImageView.image isEqual:[UIImage imageNamed:@"mynopraise"]]) {
            self.likeImageView.image = [UIImage imageNamed:@"mypraise"];
            self.praiseNumLabel.textColor = [UIColor whiteColor];
            self.praiseNumLabel.text = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[self.praiseNumLabel.text integerValue]+1]];
            self.comment.point_like = self.praiseNumLabel.text;
            [[ZMYLKDB getLKDBHelper]updateThemeComment:self.comment];
            return;
        } else {
            self.likeImageView.image = [UIImage imageNamed:@"mynopraise"];
            self.praiseNumLabel.textColor = RGB_COLOR(160, 160, 160);
            self.praiseNumLabel.text = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[self.praiseNumLabel.text integerValue]-1]];
            self.comment.point_like = self.praiseNumLabel.text;
            [[ZMYLKDB getLKDBHelper]updateThemeComment:self.comment];
        }
        
    } else {
        self.likeImageView.image = [UIImage imageNamed:@"mypraise"];
        self.praiseNumLabel.textColor = [UIColor whiteColor];
        self.praiseNumLabel.text = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[self.praiseNumLabel.text integerValue]+1]];
        self.comment.point_like = self.praiseNumLabel.text;
        [[ZMYLKDB getLKDBHelper]updateThemeComment:self.comment];
    }
    [[ZMYNetWorkAPI default]likeCommentWithThemeComment:self.comment Response:^(NSDictionary *resultDic) {
        
    } error:^(NSString *errorStr) {
        
    }];
}

@end
